<?php
// 随机生成10位数字ID，$autoID<=[数字种子，可取数据表的自增ID]
function auID($autoID)
{
    $autoID = $autoID;
    $autoCharacter = array("1","2","3","4","5","6","7","8","9","A","B","C","D","E");
    $len = 7-((int)log10($autoID) + 1);
    $i=1;
    $numberID = mt_rand(1, 2).mt_rand(1, 4);
    for($i;$i<=$len-1;$i++)
    {
        $numberID .= $autoCharacter[mt_rand(1, 13)];
    }

    return base_convert($numberID."E".$autoID, 16, 10);
}

$uuidArr = [];
$repeatNum = [];
$i=$j=1;
$repeatAllNum=0;
if(intval($argv[1])<=0){
    var_dump('参数非法，必须为数字');
    return false;
}
$maxNum=intval($argv[1]);
$auid=intval($argv[2]);
$times=intval($argv[3]);
while($j<=$times){
    while($i<=$maxNum){
        $uuidArr[] = auID($auid);
        $i++;
    }
    $uuidArr = array_flip($uuidArr);
    $uuidArrNum = count($uuidArr);
    $repeatNum[] = $maxNum-$uuidArrNum;
    $j++;
}
foreach($repeatNum as $v){
    $repeatAllNum += $v;
}
$repeatPercent = ($repeatAllNum / $times)*100;
var_dump($times.'次测试里，并发'.$maxNum.'个测试ID里重复ID共'.$repeatAllNum.'个,碰撞率'.$repeatPercent.'%');
return true;

